// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

/** 新增商品 POST /shops/shops/add */
export async function shopsAddUsingPost(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.shopsAddUsingPOSTParams,
  body: {},
  file?: File,
  options?: { [key: string]: any },
) {
  const formData = new FormData();

  if (file) {
    formData.append('file', file);
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele];

    if (item !== undefined && item !== null) {
      if (typeof item === 'object' && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ''));
        } else {
          formData.append(ele, JSON.stringify(item));
        }
      } else {
        formData.append(ele, item);
      }
    }
  });

  return request<API.BaseResponseboolean>('/shops/shops/add', {
    method: 'POST',
    params: {
      ...params,
    },
    data: formData,
    requestType: 'form',
    ...(options || {}),
  });
}

/** 管理员通过审批 POST /shops/shops/approve/confirm */
export async function rejectApprovalUsingPost(
  body: API.ConfirmApproveDTO,
  options?: { [key: string]: any },
) {
  return request<API.BaseResponseobject>('/shops/shops/approve/confirm', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 运营小二提交审批 POST /shops/shops/approve/initiate */
export async function initiateApprovalUsingPost(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.initiateApprovalUsingPOSTParams,
  options?: { [key: string]: any },
) {
  return request<API.BaseResponseobject>('/shops/shops/approve/initiate', {
    method: 'POST',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 管理员驳回审批 POST /shops/shops/approve/reject */
export async function rejectApprovalUsingPost1(
  body: API.RejectApproveDTO,
  options?: { [key: string]: any },
) {
  return request<API.BaseResponseobject>('/shops/shops/approve/reject', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 根据分类查询销量TOP20 POST /shops/shops/category */
export async function top20UsingPost(
  body: API.SalesDataCategoryDTO,
  options?: { [key: string]: any },
) {
  return request<API.BaseResponseSalesDataCategoryVO>('/shops/shops/category', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 删除商品 DELETE /shops/shops/delete */
export async function deleteShopsUsingDelete(body: number[], options?: { [key: string]: any }) {
  return request<API.BaseResponseboolean>('/shops/shops/delete', {
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 兑换量饼图 POST /shops/shops/excMtd */
export async function excMtdUsingPost(
  body: API.SalesDataExcMtdDTO,
  options?: { [key: string]: any },
) {
  return request<API.BaseResponseSalesDataExcMtdVO>('/shops/shops/excMtd', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** getById GET /shops/shops/getById/${param0} */
export async function getByIdUsingGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.getByIdUsingGETParams,
  options?: { [key: string]: any },
) {
  const { id: param0, ...queryParams } = params;
  return request<API.BaseResponseShopsDetailVO>(`/shops/shops/getById/${param0}`, {
    method: 'GET',
    params: { ...queryParams },
    ...(options || {}),
  });
}

/** 分页查询 POST /shops/shops/page */
export async function pageQueryUsingPost(
  body: API.ShopsQueryDTO,
  options?: { [key: string]: any },
) {
  return request<API.BaseResponsePageInfoShopsVO>('/shops/shops/page', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 统计时间段内兑换量 POST /shops/shops/statistics */
export async function getExchangeAmountUsingPost(
  body: API.SalesDataStatisticsDTO,
  options?: { [key: string]: any },
) {
  return request<API.BaseResponseSalesDataStatisticsVO>('/shops/shops/statistics', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 更新商品信息 POST /shops/shops/update */
export async function shopUpdateUsingPost(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.shopUpdateUsingPOSTParams,
  body: {},
  file?: File,
  options?: { [key: string]: any },
) {
  const formData = new FormData();

  if (file) {
    formData.append('file', file);
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele];

    if (item !== undefined && item !== null) {
      if (typeof item === 'object' && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ''));
        } else {
          formData.append(ele, JSON.stringify(item));
        }
      } else {
        formData.append(ele, item);
      }
    }
  });

  return request<API.BaseResponseboolean>('/shops/shops/update', {
    method: 'POST',
    params: {
      ...params,
    },
    data: formData,
    requestType: 'form',
    ...(options || {}),
  });
}
